package controller;

import dao.ProductTypeDao;

import pojo.product.ProductTypeEntity;


import java.io.IOException;

/**
 * @author Limohan
 */
public class ProductTypeController {
    private final ProductTypeDao productTypeDao = new ProductTypeDao();
    private static final ProductTypeController productTypeController = new ProductTypeController();
    private ProductTypeController(){}

    public static ProductTypeController getInstance(){
        return productTypeController;
    }

    //新增
    public String addType(ProductTypeEntity productTypeEntity) throws IOException {
        productTypeEntity.setId("1");
        String id =productTypeDao.getMaxId();
        productTypeEntity.setId(id);
        if(!(productTypeDao.isType(productTypeEntity.getType()))){
            productTypeDao.saveType(productTypeEntity);
            return "注册成功";
        }
        return "已经注册过啦";
    }
}
